package com.demo.bridge.hm;

/**
 * @author lkz
 * @ClassName: VideoFile
 * @description:
 * @date 2022/3/15 18:58
 */
// 实现化角色
public interface VideoFile {

    void decode(String fileName);
}
// 具体实现化角色
class AVIFile implements VideoFile{

    @Override
    public void decode(String fileName) {
        System.out.println("---AVIFile---:"+fileName);
    }
}
// 同上
class REVBBFile implements VideoFile {

    public void decode(String fileName) {
        System.out.println("rmvb文件：" + fileName);
    }
}
// 抽象化角色
abstract  class  OperatingSystemVersion{

    protected VideoFile videoFile;

    public OperatingSystemVersion(VideoFile videoFile) {
        this.videoFile = videoFile;
    }

    public abstract void play(String fileName);


}

//扩展抽象化角色
class Windows extends OperatingSystemVersion {

    public Windows(VideoFile videoFile) {
        super(videoFile);
    }

    public void play(String fileName) {
        videoFile.decode(fileName);
    }
}

//同上
 class Mac extends OperatingSystemVersion {

    public Mac(VideoFile videoFile) {
        super(videoFile);
    }

    public void play(String fileName) {
        videoFile.decode(fileName);
    }
}

//测试类
class Client {
    public static void main(String[] args) {
        OperatingSystemVersion os = new Windows(new REVBBFile());
        os.play("战狼3");
    }
}


